<?php /* Smarty version 2.6.20, created on 2011-10-25 17:47:49
         compiled from _core/pagemanager/mvc/control/handlepagecomparisonbymonth.tpl */ ?>
function HandlePageComparisonByMonth(gui, operator, now, options) {
  this._gui = gui;
  this._operator = operator;
  this._now = now;
  this._options = options
  
  this._createElements();
};

HandlePageComparisonByMonth.prototype._createElements = function() {
  var _self = this;
  this._popupBox = new PopupBox();
  
  tr = this._gui.detail.mainTable.insertRow(-1);
  td = tr.insertCell(-1);
  td.style.backgroundColor = '#fff';
  td.colSpan = 14;
  td.appendChild(DOMUtils.getLoadingImage());
  
  this._loadData();
};

HandlePageComparisonByMonth.prototype._loadData = function() {
  this._results = null;
  this._retrieveResults();
};

HandlePageComparisonByMonth.prototype._verifyData = function() {
  if (this._results) {
    this._updateElements();
  }
};

HandlePageComparisonByMonth.prototype._retrieveResults = function() {
  var _self = this;
  var args = '';
  new RequestUtils()._mysql('iecompbymonth', args, function(result, params) { _self._results = result;
                                                                               _self._verifyData.call(_self);
                                                                             }, null);
};

HandlePageComparisonByMonth.prototype._updateElements = function() {
  var _self = this;

  DOMUtils.removeTableRows(this._gui.detail.mainTable, 1);
  ChartUtils.statsmonth(this._gui.detail.graph, this._results);
  
  var total = 0;
  /*--main table--*/
  for (var i = 0, il = this._results.length; i < il; i++) {
    var result = this._results[i];
    tr = this._gui.detail.mainTable.insertRow(-1);
    tr.style.backgroundColor = (i % 2 == 0) ? '#cad9eb' : '#e1eacd' ;
    td = tr.insertCell(-1);
    td.rowSpan = (result.mains.length == 0) ? 1 : result.mains.length;
    td.style.fontWeight = 'bold';
    td.style.fontSize = '9pt';
    td.style.color = '#694247';
    td.style.padding = '0 0 0 10px';
    td.appendChild(document.createTextNode(this._monthFull(result.month)));
    if (result.mains.length == 0) {
      td = tr.insertCell(-1);
      td.colSpan = 13;
      td.style.height = '24px';
    }
    for (var j = 0, jl = result.mains.length; j < jl; j++) {
      var main = result.mains[j];
      if (j != 0) {
        tr = this._gui.detail.mainTable.insertRow(-1);
        tr.style.backgroundColor = (i % 2 == 0) ? '#cad9eb' : '#e1eacd' ;
      }
      td = tr.insertCell(-1);
      td.className = 'pagecomparisonbymonth_td9';
      td.appendChild(document.createTextNode(main.year));
      td = tr.insertCell(-1);
      td.className = 'pagecomparisonbymonth_td10';
      td.appendChild(document.createTextNode('$' + parseFloat(main.total).toFixed(2)));
      td = tr.insertCell(-1);
      td.className = 'pagecomparisonbymonth_td11';
      td.appendChild(document.createTextNode(main.tolcus));
      td = tr.insertCell(-1);
      td.className = 'pagecomparisonbymonth_td12';
      td.appendChild(document.createTextNode('$' + parseFloat(main.wed).toFixed(2)));
      td = tr.insertCell(-1);
      td.className = 'pagecomparisonbymonth_td11';
      td.appendChild(document.createTextNode(main.wedcus));
      td = tr.insertCell(-1);
      td.className = 'pagecomparisonbymonth_td12';
      td.appendChild(document.createTextNode('$' + parseFloat(main.pre).toFixed(2)));
      td = tr.insertCell(-1);
      td.className = 'pagecomparisonbymonth_td11';
      td.appendChild(document.createTextNode(main.precus));
      td = tr.insertCell(-1);
      td.className = 'pagecomparisonbymonth_td12';
      td.appendChild(document.createTextNode('$' + parseFloat(main.por).toFixed(2)));
      td = tr.insertCell(-1);
      td.className = 'pagecomparisonbymonth_td11';
      td.appendChild(document.createTextNode(main.porcus));
      td = tr.insertCell(-1);
      td.className = 'pagecomparisonbymonth_td12';
      td.appendChild(document.createTextNode('$' + parseFloat(main.eng).toFixed(2)));
      td = tr.insertCell(-1);
      td.className = 'pagecomparisonbymonth_td11';
      td.appendChild(document.createTextNode(main.engcus));
      td = tr.insertCell(-1);
      td.className = 'pagecomparisonbymonth_td12';
      td.appendChild(document.createTextNode('$' + parseFloat(main.oth).toFixed(2)));
      td = tr.insertCell(-1);
      td.className = 'pagecomparisonbymonth_td11';
      td.appendChild(document.createTextNode(main.othcus));
    }
  }
};

HandlePageComparisonByMonth.prototype._monthFull = function(value) {
  var str = '';
  if (value == 1) {
    str = 'January';
  } else if (value == 2) {
    str = 'February';
  } else if (value == 3) {
    str = 'March';
  } else if (value == 4) {
    str = 'April';
  } else if (value == 5) {
    str = 'May';
  } else if (value == 6) {
    str = 'June';
  } else if (value == 7) {
    str = 'July';
  } else if (value == 8) {
    str = 'August';
  } else if (value == 9) {
    str = 'September';
  } else if (value == 10) {
    str = 'October';
  } else if (value == 11) {
    str = 'November';
  } else if (value == 12) {
    str = 'December';
  }
  return str;
};